package dl.bukkit.myststus.function.trigger.imp;

import dl.bukkit.myststus.api.playerdata.ClientSizeData;
import dl.bukkit.myststus.configuration.imp.Config;
import dl.bukkit.myststus.hook.VexViewHook;
import dl.bukkit.myststus.library.ats.GComponent;
import dl.bukkit.myststus.function.trigger.TriggerHud;
import lk.vexview.event.PlayerClientWindowSizeEvent;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;

@GComponent(
        key = "client",
        author = "DogLong"
)
public class ClientTrigger extends TriggerHud<PlayerClientWindowSizeEvent> {
    @Override
    public boolean isRemove(PlayerClientWindowSizeEvent event) {
        return false;
    }

    @Override
    public void trigger(PlayerClientWindowSizeEvent event) {
        ClientSizeData.getInst(getPlayer(event)).setup(event);
    }

    @Override
    public Class<PlayerClientWindowSizeEvent> getEvent() {
        return PlayerClientWindowSizeEvent.class;
    }

    @Override
    public Player getPlayer(PlayerClientWindowSizeEvent event) {
        return event.getPlayer();
    }

    @Override
    public Entity getTarget(PlayerClientWindowSizeEvent event) {
        return event.getPlayer();
    }

    @Override
    public boolean isRegister() {
        return VexViewHook.hasPlugin() && Config.getInst().getBoolean("Trigger.Client");
    }
}
